﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Comm;

public partial class Web_Admin_Admin_admin_list : AdminPageBase
{
    private BLL.Admin bll = new BLL.Admin();
    protected void Page_Load(object sender, EventArgs e)
    {
        base.CheckPopedomInfoRedirect(1001, 1);
        but_delete.Enabled = base.CheckPopedomInfo(1001, 8);
        but_pass.Enabled = but_cancelpass.Enabled = base.CheckPopedomInfo(1001, 16);
        if (!IsPostBack)
        {
            loadData();
        }
    }

    /// <summary>
    /// 加载数据
    /// </summary>
    private void loadData()
    {
        string strWhere = "";
        string username = base.QueryString("txt_UserName");
        if (!string.IsNullOrEmpty(username))
        {
            strWhere += @"Username like '%" + username + "%'";
            txt_UserName.Text = base.PrototypeQuery("txt_UserName");
        }
        Model.PageData data = bll.GetList(AppClass.PageSize, base.PageIndex, strWhere, "AddTime desc");
        rpList.DataSource = data.DataSoure;
        rpList.DataBind();
        pgServer.PageSize = AppClass.PageSize;
        pgServer.RecordCount = data.Count;
        pgServer.DataBind();
        lit_nodata.Visible = data.Count < 1 ? true : false;
    }

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_delete_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (string.IsNullOrEmpty(ids))
        {
            return;
        }

        bll.DeleteList(ids);
        base.AddLog(3, "管理员ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 审核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_pass_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (string.IsNullOrEmpty(ids))
        {
            return;
        }

        bll.UpdateIsPass(true, ids);
        base.AddLog(2, "审核通过管理员ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 取消审核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_cancelpass_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (string.IsNullOrEmpty(ids))
        {
            return;
        }

        bll.UpdateIsPass(false, ids);
        base.AddLog(2, "取消审核管理员ID：" + ids);
        loadData();
    }
}
